<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>复习笔记</title>
  <style>
    body {
      margin: 0;
      padding: 0;
      font-family: Arial, sans-serif;
      font-size: 14px;
      background: #f5f5f5;
    }
    
    /* 主布局 */
    .main-layout {
      display: flex;
      height: 100vh;
      overflow: hidden;
    }
    
    /* 左侧笔记复习区域 */
    .left-panel {
      width: 75%;
      background: #f5f5f5;
      overflow-y: auto;
      min-width: 400px;
      max-width: 80%;
    }
    
    /* 拖拽分隔条 */
    .resizer {
      width: 8px;
      background: #e0e0e0;
      cursor: col-resize;
      position: relative;
      transition: background-color 0.2s;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    
    .resizer:hover {
      background: #007bff;
    }
    
    .resizer:active {
      background: #0056b3;
    }
    
    .resizer-handle {
      width: 4px;
      height: 40px;
      background: #999;
      border-radius: 2px;
      transition: background-color 0.2s;
    }
    
    .resizer:hover .resizer-handle {
      background: #fff;
    }
    
    .resizer:active .resizer-handle {
      background: #fff;
    }
    
    /* 右侧对话区域 */
    .right-panel {
      flex: 1;
      background: #ffffff;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      min-width: 300px;
    }
    
    .container {
      max-width: none;
      margin: 0;
      padding: 20px;
      height: 100%;
      box-sizing: border-box;
    }
    
    .header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 30px;
      padding-bottom: 15px;
      border-bottom: 2px solid #e0e0e0;
    }
    .header h1 {
      margin: 0;
      color: #333;
      font-size: 24px;
    }
    .back-btn {
      padding: 8px 16px;
      background-color: #6c757d;
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      font-size: 14px;
      text-decoration: none;
      display: inline-block;
    }
    .back-btn:hover {
      background-color: #5a6268;
    }
    .review-content {
      background: white;
      border-radius: 8px;
      padding: 30px;
      box-shadow: 0 2px 10px rgba(0,0,0,0.1);
      min-height: 400px;
    }
    .loading {
      text-align: center;
      color: #666;
      font-size: 16px;
      padding: 50px 0;
    }
    .note-card {
      border: 1px solid #e0e0e0;
      border-radius: 8px;
      padding: 20px;
      margin-bottom: 20px;
      background: #fafafa;
    }
    .note-title {
      font-size: 18px;
      font-weight: bold;
      color: #333;
      margin-bottom: 10px;
    }
    .note-meta {
      display: flex;
      gap: 20px;
      margin-bottom: 15px;
      font-size: 12px;
      color: #666;
      flex-wrap: wrap;
    }
    .note-keywords {
      color: #007bff;
      font-weight: bold;
    }
    .note-content {
      background: white;
      padding: 15px;
      border-radius: 4px;
      border-left: 4px solid #4CAF50;
      margin-bottom: 15px;
    }
    .note-thoughts {
      background: #fff3cd;
      padding: 15px;
      border-radius: 4px;
      border-left: 4px solid #ffc107;
    }
    .controls {
      display: flex;
      justify-content: center;
      gap: 15px;
      margin-top: 30px;
    }
    .control-btn {
      padding: 10px 20px;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      font-size: 14px;
      font-weight: bold;
    }
    .prev-btn {
      background-color: #6c757d;
      color: white;
    }
    .prev-btn:hover {
      background-color: #5a6268;
    }
    .edit-btn:hover {
      background-color: #138496 !important;
    }
    .next-btn {
      background-color: #007bff;
      color: white;
    }
    .next-btn:hover {
      background-color: #0056b3;
    }
    .control-btn:disabled {
      background-color: #e0e0e0;
      color: #999;
      cursor: not-allowed;
    }
    .progress {
      text-align: center;
      margin-bottom: 20px;
      color: #666;
      font-size: 14px;
    }
    .review-actions {
      text-align: center;
      margin-top: 20px;
    }
    .review-actions .control-btn {
      background-color: #28a745;
      color: white;
      padding: 12px 24px;
      font-size: 16px;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      transition: background-color 0.2s;
    }
    .review-actions .control-btn:hover {
      background-color: #218838;
    }
    .review-actions .control-btn:disabled {
      background-color: #6c757d;
      cursor: not-allowed;
    }
    
    /* 右侧对话区域样式 */
    .chat-header {
      padding: 20px;
      border-bottom: 2px solid #e0e0e0;
      background: #f8f9fa;
    }
    .chat-header h2 {
      margin: 0;
      color: #333;
      font-size: 20px;
    }
    
    .chat-messages {
      flex: 1;
      padding: 20px;
      overflow-y: auto;
      background: #f8f9fa;
    }
    
    .message {
      margin-bottom: 15px;
      display: flex;
      align-items: flex-start;
    }
    
    .message.user {
      justify-content: flex-end;
    }
    
    .message.assistant {
      justify-content: flex-start;
    }
    
    .message-content {
      max-width: 95%;
      padding: 12px 16px;
      border-radius: 18px;
      font-size: 14px;
      line-height: 1.4;
    }
    
    .message.user .message-content {
      background: #007bff;
      color: white;
      border-bottom-right-radius: 4px;
    }
    
    .message.assistant .message-content {
      background: white;
      color: #333;
      border: 1px solid #e0e0e0;
      border-bottom-left-radius: 4px;
    }
    
    .message-time {
      font-size: 11px;
      color: #999;
      margin-top: 4px;
      text-align: center;
    }
    
    .chat-input-area {
      padding: 20px;
      border-top: 1px solid #e0e0e0;
      background: white;
    }
    
    .chat-input-container {
      display: flex;
      gap: 10px;
      align-items: flex-end;
    }
    
    .chat-input {
      flex: 1;
      padding: 12px;
      border: 1px solid #ddd;
      border-radius: 20px;
      font-size: 14px;
      resize: none;
      min-height: 40px;
      max-height: 120px;
      outline: none;
    }
    
    .chat-input:focus {
      border-color: #007bff;
    }
    
    .send-btn {
      padding: 12px 20px;
      background: #007bff;
      color: white;
      border: none;
      border-radius: 20px;
      cursor: pointer;
      font-size: 14px;
      font-weight: bold;
      transition: background-color 0.2s;
    }
    
    .send-btn:hover {
      background: #0056b3;
    }
    
    .send-btn:disabled {
      background: #e0e0e0;
      color: #999;
      cursor: not-allowed;
    }
    
    .welcome-message {
      text-align: center;
      color: #666;
      font-size: 16px;
      margin-top: 50px;
    }
    
    /* 打字动画 */
    @keyframes typing {
      0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
      }
      30% {
        transform: translateY(-10px);
        opacity: 1;
      }
    }
    
    /* 配置相关的样式 */
    .config-warning {
      background: #fff3cd;
      color: #856404;
      border: 1px solid #ffeaa7;
      border-radius: 4px;
      padding: 10px;
      margin: 10px 0;
      font-size: 14px;
    }
    
    /* 问答模式按钮样式 */
    .qa-toggle-btn {
      transition: all 0.2s ease;
    }
    
    .qa-toggle-btn:hover {
      transform: translateY(-1px);
      box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .qa-toggle-btn.active {
      background: #28a745 !important;
      color: white !important;
      border-color: #28a745 !important;
    }
    
    /* 思考模式按钮样式 */
    .thinking-toggle-btn {
      transition: all 0.2s ease;
    }
    
    .thinking-toggle-btn:hover {
      transform: translateY(-1px);
      box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .thinking-toggle-btn.active {
      background: #ffc107 !important;
      color: #212529 !important;
      border-color: #ffc107 !important;
    }
    
    /* 思考模式消息样式 */
    .thinking-content {
      background: #fff3cd;
      border-left: 4px solid #ffc107;
      padding: 12px;
      margin-bottom: 12px;
      border-radius: 4px;
    }
    
    .answer-content {
      background: #d4edda;
      border-left: 4px solid #28a745;
      padding: 12px;
      border-radius: 4px;
    }
    
    .edit-modal {
      background: #fff;
      border-radius: 8px;
      box-shadow: 0 2px 16px rgba(0,0,0,0.18);
      padding: 24px 24px 12px 24px;
      width: 380px;
      max-width: 96vw;
      position: fixed;
      left: 50%;
      top: 50%;
      transform: translate(-50%,-50%);
      z-index: 10001;
    }
    #editModalMask {
      position: fixed;
      left: 0;top: 0;right: 0;bottom: 0;
      background: rgba(0,0,0,0.18);
      z-index: 10000;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .edit-modal-title {
      font-size: 18px;
      font-weight: bold;
      margin-bottom: 16px;
      text-align: left;
    }
    .form-group {
      margin-bottom: 10px;
    }
    .form-group label {
      display: block;
      margin-bottom: 3px;
      font-weight: bold;
    }
    .form-group input, .form-group select, .form-group textarea {
      width: 100%;
      padding: 5px;
      border: 1px solid #ccc;
      border-radius: 3px;
      box-sizing: border-box;
    }
    .form-group textarea {
      resize: vertical;
    }
    
    /* 全屏编辑弹窗样式 */
    .fullscreen-modal {
      width: 98vw !important;
      height: 96vh !important;
      max-width: none !important;
      max-height: none !important;
      left: 50% !important;
      top: 50% !important;
      transform: translate(-50%, -50%) !important;
      z-index: 10002 !important;
      padding: 32px 32px 16px 32px !important;
      box-sizing: border-box !important;
      overflow: auto !important;
    }
  </style>
</head>
<body>
  <div class="main-layout">
    <!-- 左侧笔记复习区域 -->
    <div class="left-panel" id="leftPanel">
      <div class="container">
        <div class="header">
          <h1>📚 复习笔记</h1>
          <div style="display: flex; align-items: center; gap: 10px;">
            <a href="#" class="back-btn" id="prevBtn">换一条</a>
            <a href="#" class="back-btn" id="backBtn">返回</a>
          </div>
        </div>
        
        <div class="review-content">
          <div id="loading" class="loading">
            正在加载笔记数据...
          </div>
          
          <div id="noteDisplay" style="display: none;">
            <div class="progress">
              <div style="text-align: right; margin-top: 8px;">
                <button class="control-btn edit-btn" id="editBtn" style="background-color: #17a2b8; color: white;">✏️ 编辑笔记</button>
              </div>
            </div>
            
            <div class="note-card">
              <div class="note-title" id="noteTitle">笔记标题</div>
              <div class="note-meta">
                <span id="noteType">类型：</span>
                <span id="noteKeywords" class="note-keywords">关键词：</span>
                <span id="noteSource">来源：</span>
                <span id="noteDate">创建时间：</span>
                <span id="noteReviewCount" style="color: #666; font-size: 12px;">该笔记复习：1 次</span>
              </div>
              <div class="note-content" id="noteContent">
                笔记内容将在这里显示...
              </div>
              <div class="note-thoughts" id="noteThoughts">
                思考内容将在这里显示...
              </div>
            </div>
            
            <div class="controls">
              <!-- <button class="control-btn edit-btn" id="editBtn" style="background-color: #17a2b8; color: white;">✏️ 编辑笔记</button> -->
            </div>
            <div class="review-actions">
              <button class="control-btn" id="reviewedBtn">
                ✅ 我已复习
              </button>
            </div>
          </div>
        </div>
      </div>
    </div>
    
    <!-- 拖拽分隔条 -->
    <div class="resizer" id="resizer">
      <div class="resizer-handle"></div>
    </div>
    
    <!-- 右侧对话区域 -->
    <div class="right-panel" id="rightPanel">
      <div class="chat-header">
        <h2>💬 AI 助手</h2>
        <div style="position: absolute; top: 15px; right: 120px; display: flex; gap: 8px; align-items: center;">
          <select id="modelSelect" style="padding: 4px 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 12px; background: #f8f9fa;">
            <!-- 模型选项将由JavaScript动态生成 -->
          </select>
          <button id="settingsBtn" style="padding: 4px 8px; background: #f8f9fa; border: 1px solid #ddd; border-radius: 4px; cursor: pointer; font-size: 12px;">⚙️</button>
        </div>
      </div>
      
      <div class="chat-messages" id="chatMessages">
        <div class="welcome-message">
          <p>👋 你好！我是你的AI学习助手</p>
          <p>你可以问我关于笔记内容的问题，我会尽力帮助你理解和记忆</p>
        </div>
      </div>
      
      <div class="chat-input-area">
        <div style="margin-bottom: 10px; display: flex; gap: 8px; align-items: center;">
            <button id="noteQaBtn" class="qa-toggle-btn" style="padding: 6px 12px; background: #e9ecef; border: 1px solid #ced4da; border-radius: 4px; cursor: pointer; font-size: 12px; color: #495057;">
              📝 笔记问答
            </button>
            <button id="thinkingBtn" class="thinking-toggle-btn" style="padding: 6px 12px; background: #e9ecef; border: 1px solid #ced4da; border-radius: 4px; cursor: pointer; font-size: 12px; color: #495057;">
              🧠 思考模式
            </button>
        </div>
        <div class="chat-input-container">
          <textarea 
            class="chat-input" 
            id="chatInput" 
            placeholder="请输入你的问题..."
            rows="1"
          ></textarea>
          <button class="send-btn" id="sendBtn">发送</button>
        </div>
      </div>
    </div>
  </div>
  
  <!-- 编辑笔记模态框 -->
  <div style="display:none;" id="editModalMask">
    <div id="editModal" class="edit-modal">
      <div style="display:flex;justify-content:space-between;align-items:center;width:100%;">
        <div class="edit-modal-title" style="white-space:nowrap;">修改笔记</div>
        <button id="fullscreenToggleBtn" title="最大化" style="background:none;border:none;cursor:pointer;padding:0;line-height:1;align-self:flex-start;">
          <svg id="fullscreenIcon" width="22" height="22" viewBox="0 0 24 24"><path d="M4 4h7V2H2v9h2V4zm16 0v7h2V2h-9v2h7zm0 16h-7v2h9v-9h-2v7zM4 20v-7H2v9h9v-2H4z"/></svg>
        </button>
      </div>
      <form id="editForm">
        <input type="hidden" id="editId">
        <div class="form-group">
          <label for="editTitle">标题：</label>
          <input type="text" id="editTitle" name="title" required>
        </div>
        <div class="form-group">
          <label for="editType">类型：</label>
          <select id="editType" name="type" required>
            <option value="">请选择类型</option>
            <option value="读书笔记">读书笔记</option>
            <option value="反思">反思</option>
            <option value="知识点">知识点</option>
          </select>
        </div>
        <div class="form-group">
          <label for="editKeyList">关键词：</label>
          <input type="text" id="editKeyList" name="key_list">
        </div>
        <div class="form-group">
          <label for="editSource">来源：</label>
          <input type="text" id="editSource" name="source">
        </div>
        <div class="form-group">
          <label for="editContent">内容：</label>
          <textarea id="editContent" name="content" style="height:80px;"></textarea>
        </div>
        <div class="form-group">
          <label for="editThink">思考：</label>
          <textarea id="editThink" name="think" style="height:80px;"></textarea>
        </div>
        <div style="text-align:right;margin-top:10px;">
          <button type="button" id="editCancelBtn" style="margin-right:10px;background:#eee;color:#333;">取消</button>
          <button type="submit" id="editSaveBtn">确认更新</button>
        </div>
      </form>
    </div>
  </div>
  
  <script src="config.js"></script>
  <script src="review.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
</body>
</html> 